using UnityEngine;
using System.Collections;

public class SwingingLight : Reaction {
	
	Transform thisTransform;
	
	void Start()
	{
		thisTransform = transform;
		
		StartCoroutine(swing());
	}
	
	protected override void pain (float amount)
	{
	//	StopCoroutine("swing");
	//	StartCoroutine("swing", amount);
	}
	
	IEnumerator swing()
	{
		float modifier, swingTime = 0;
		Vector3 initPos = thisTransform.position;
		Vector3 thisPos = initPos;
		while(true)
		{
			modifier = GameController.instance.PainLevel;
			//thisPos.x = initPos.x + (modifier/2 * Mathf.Cos(swingTime * modifier/10));
			//thisPos.z = initPos.z + (modifier/2 * Mathf.Cos(swingTime * modifier/10));
			thisPos.x = initPos.x + (30 *  Mathf.Cos(swingTime));
			thisPos.z = initPos.z + ( Mathf.Cos(swingTime));
			thisTransform.position = thisPos;
			
			yield return 0;
			swingTime += Time.deltaTime;
		}
	}
}
